// 引入模块
//剩下的全部用路由懒加载引入
import Home from '@/pages/Home'
//引入二级路由组件
import GroupOrder from '@/pages/Center/groupOrder'
//路由配置信息
export default [
    {
        path: "/center",
        component: () => import('@/pages/Center'),
        meta: { show: true, },
        //二级路由
        children: [
            {
                //要么写全，要么就写当前
                path: 'myorder',
                component: () => import('@/pages/Center/myOrder'),
            },
            {
                path: 'grouporder',
                component: GroupOrder,
            },
            {
                path: '/center',
                redirect: '/center/myorder'
            }
        ]
    },
    {
        path: "/paysuccess",
        component: () => import('@/pages/PaySuccess'),
        meta: { show: true, },
    },
    {
        path: "/pay",
        component: () => import('@/pages/Pay'),
        meta: { show: true, },
        beforeEnter: (to, from, next) => {
            //支付页面，必须从交易页面来
            if (from.path == '/trade') {
                next();
            } else {
                //中断路由跳转，跳回from之间的路由
                next(false);
            }
        }
    },
    {
        path: "/trade",
        component: () => import('@/pages/Trade'),
        meta: { show: true, },
        //路由独享守卫
        beforeEnter: (to, from, next) => {
            //去交易页面，必须从购物车来
            if (from.path == "/shopcart") {
                next();
            } else {
                //中断路由跳转，跳回from之间的路由
                next(false);
            }
        }
    },
    {
        path: "/shopcart",
        component: () => import('@/pages/ShopCart'),
        meta: { show: true, },
    },
    {
        path: "/addcartsuccess",
        component: () => import('@/pages/AddCartSuccess'),
        name: "addcartsuccess",
        meta: { show: true, },
    },
    {
        path: "/detail/:skuid",
        component: () => import('@/pages/Detail'),
        meta: { show: true, },
    },
    {
        path: "/home",
        component: Home,
        //路由元信息
        meta: { show: true, },
    },
    {
        path: "/search/:keyword?",
        component: () => import('@/pages/Search'),
        meta: { show: true, },
        name: "search",
    },
    {
        path: "/login",
        component: () => import('@/pages/Login'),
        meta: { show: false, },
    },
    {
        path: '/register',
        component: () => import('@/pages/Register'),
        meta: { show: false, },
    },
    // 重定向，在项目跑起来的时候，访问/,立马让他定向到首页
    {
        path: '*',
        redirect: '/home'
    }
]